package com.example.administrator.activity.boradcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;

/**
 * 广播接受者：接受系统或App的广播
 * 1）onReceive（）方法：
 *    一旦接收到已订阅的广播，自动调用该方法
 * 2）注册/订阅广播
 *    拨打电话时系统会发送 action为android.intent.action.NEW_OUTGOING_
 */
public class MyReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO: This method is called when the BroadcastReceiver is receiving
        // an Intent broadcast.
//        throw new UnsupportedOperationException("Not yet implemented");
        String number=getResultData();
        SharedPreferences sp=context.getSharedPreferences("phone",Context.MODE_PRIVATE);
        String phone=sp.getString("phone",null);
        if (number.equals(phone)){
            setResultData(null);
        }
    }
}
